/**
 * Project: push-center-biz-dal
 * 
 * File Created at 2014年10月9日
 * 
 * Copyright 2012 Greenline.com Corporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Greenline Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Greenline.com.
 */
package com.greenline.push.dal.pushcenter.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.greenline.push.dal.base.BaseDAO;
import com.greenline.push.dal.pushcenter.GroupUserDao;
import com.greenline.push.dal.pushcenter.dataobject.GroupUserDO;
import com.greenline.push.dal.query.GroupUserQuery;

/**
 * @Type GroupUserDAOImpl
 * @Desc
 * @author shuai.zuo
 * @date 2014年10月9日
 * @Version V1.0
 */
public class GroupUserDAOImpl extends BaseDAO implements GroupUserDao {

    /*
     * (non-Javadoc)
     * 
     * @see com.greenline.push.dal.pushcenter.GroupUserDao#insert(com.greenline.
     * push.dal.pushcenter.dataobject.groupUserDO)
     */
    @Override
    public Long insert(GroupUserDO groupUserDO) {
        return (Long) super.getSqlMapClientTemplate().insert("groupUser.insert", groupUserDO);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.greenline.push.dal.pushcenter.groupUserDAO#getgroupUserById(java
     * .lang.Long)
     */
    @Override
    public GroupUserDO getById(Long id) {
        return (GroupUserDO) super.getSqlMapClientTemplate().queryForObject("groupUser.find_by_id", id);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.greenline.push.dal.pushcenter.groupUserDAO#update(com.greenline.
     * push.dal.pushcenter.dataobject.groupUserDO)
     */
    @Override
    public int update(GroupUserDO groupUserDO) {
        return super.getSqlMapClientTemplate().update("groupUser.update", groupUserDO);
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * com.greenline.push.dal.pushcenter.groupUserDAO#listByQuery(com.greenline
     * .push.dal.query.groupUserQuery)
     */
    @Override
    public GroupUserQuery listByQuery(GroupUserQuery query) {
        return (GroupUserQuery) super.listByQuery("groupUser.list_by_query", query);
    }

    @Override
    public int deleteById(Long id) {
        return super.getSqlMapClientTemplate().update("groupUser.delete", id);
    }

    @Override
    public int delete(Long gid, Long uid) {
        Map<String, Long> params = new HashMap<String, Long>();
        params.put("gid", gid);
        params.put("uid", uid);
        return super.getSqlMapClientTemplate().delete("groupUser.delete_by_uid_gid", params);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<GroupUserDO> queryByGid(Long gid) {
        return super.getSqlMapClientTemplate().queryForList("groupUser.query_by_gid", gid);
    }

}
